package POJO;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;



@Entity
@Table(name = "PRODUCT")
public class Product {
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name = "Product_Id")
	private int productId;
	
	@Column(name = "Product_Name")
	private String productName;
	
	@Column(name = "Tag")
	private String tag;
	
	@Column(name = "Description")
	private String description;
	
	@Column(name = "Detail_Info")
	private String detailInfo;
	
	@Column(name = "Status")
	private String status;
	
	@Column(name = "Deleted")
	private int deleted;
	
	@Column(name = "Date_Create")
	private Date dateCreate;
	
	@ManyToOne()
	@JoinColumn(name = "Brand_Id")
	private Brand brand;

	@ManyToMany(fetch = FetchType.EAGER, mappedBy = "products")
	private Set<Category> categories;
	
	@OneToMany(fetch = FetchType.EAGER, mappedBy="product")
	@Fetch(FetchMode.SELECT)
    private Set<ProductDetail> productDetails = new HashSet<ProductDetail>();

	public Product(String product_name, String tag, String description,
			String detail_info, String status, int deleted, Brand brand) {
		super();
		this.productName = product_name;
		this.tag = tag;
		this.description = description;
		this.detailInfo = detail_info;
		this.status = status;
		this.deleted = deleted;
		this.brand = brand;
	}

	public Product(String productName, String tag, String description,
			String detailInfo, String status, int deleted, Brand brand,
			Set<Category> categories) {
		super();
		this.productName = productName;
		this.tag = tag;
		this.description = description;
		this.detailInfo = detailInfo;
		this.status = status;
		this.deleted = deleted;
		this.brand = brand;
		this.categories = categories;
	}

	public Product(String productName, String tag, String description,
			String detailInfo, String status, int deleted, Brand brand, 
			Set<Category> categories, Date dateCreate) {
		super();
		this.productName = productName;
		this.tag = tag;
		this.description = description;
		this.detailInfo = detailInfo;
		this.status = status;
		this.deleted = deleted;
		this.dateCreate = dateCreate;
		this.brand = brand;
		this.categories = categories;
	}

	public Product() {
		super();
	}

	public int getProductId() {
		return productId;
	}

	public void setProductId(int productId) {
		this.productId = productId;
	}

	public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}

	public String getTag() {
		return tag;
	}

	public void setTag(String tag) {
		this.tag = tag;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getDetailInfo() {
		return detailInfo;
	}

	public void setDetailInfo(String detailInfo) {
		this.detailInfo = detailInfo;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public int getDeleted() {
		return deleted;
	}

	public void setDeleted(int deleted) {
		this.deleted = deleted;
	}

	public Brand getBrand() {
		return brand;
	}

	public void setBrand(Brand brand) {
		this.brand = brand;
	}

	public Set<Category> getCategories() {
		return categories;
	}

	public void setCategories(Set<Category> categories) {
		this.categories = categories;
	}

	public Date getDateCreate() {
		return dateCreate;
	}

	public void setDateCreate(Date dateCreate) {
		this.dateCreate = dateCreate;
	}
	
	public Set<ProductDetail> getProductDetails() {
		return productDetails;
	}

	public void setProductDetails(Set<ProductDetail> productDetails) {
		this.productDetails = productDetails;
	}
}
